
#include <string>

#include "Entities/BaseEntity.h"
#include "Entities/ComponentTypeEnum.h"
#include "CameraComponent.h"
#include "Base.h"
#include "Game/Game.h"
#include "Maths/Matrix4.h"
#include "Resources/ResourceManager.h"
#include "Transform2DComponent.h"
#include "EventHandler/EventHandler.h"
#include "StringUtils.h"
#include "Maths/Math.h"
#include "EngineInfo.h"
#include "Entities/Components/CameraControllers/CameraController.h"

namespace CasaEngine
{

/**
 * 
 */
CameraComponent::CameraComponent(BaseEntity* pEntity_, int type_)
	: Component(pEntity_, type_),
	m_pCameraController(NULL)
{
	
}

/**
 * 
 */
CameraComponent::~CameraComponent()
{
	if (m_pCameraController != NULL)
	{
		delete m_pCameraController;
	}
}

/**
 * 
 */
void CameraComponent::Update(const GameTime& gameTime_)
{
	if (m_pCameraController != NULL)
	{
		m_pCameraController->Update(gameTime_);
	}
}

/**
 * 
 */
/*void CameraComponent::HandleEvent(const Event* pEvent_)
{

}*/

/**
 * 
 */
Matrix4 CameraComponent::GetProjectionMatrix() const
{
	return m_ProjectionMatrix;
}

/**
 * 
 */
Matrix4 CameraComponent::GetViewMatrix() const
{
	if (m_pCameraController != NULL)
	{
		return m_pCameraController->ViewMatrix();
	}

	return m_ViewMatrix;
}

/**
 * 
 */
ICameraController * CameraComponent::CameraController() const 
{ 
	return m_pCameraController; 
}

/**
 * 
 */
void CameraComponent::CameraController(ICameraController * val) 
{ 
	m_pCameraController = val;
	m_pCameraController->Initialize();
}

/**
 * 
 */
void CameraComponent::Write(std::ostream& /*os*/) const
{

}

/**
 * 
 */
void CameraComponent::Read (std::ifstream& /*is*/)
{

}

} // namespace CasaEngine
